package edu.scau.core.Enum;

import io.swagger.v3.oas.annotations.media.Schema;

@Schema(name = "尺码表", description = "衣服尺码表枚举类")
public enum SizeEnum {

    @Schema(description = "小码")
    S("S"),

    @Schema(description = "中码")
    M("M"),

    @Schema(description = "大码")
    L("L"),

    @Schema(description = "加大码")
    XL("XL");

    private final String size;

    SizeEnum(String size) {
        this.size = size;
    }

    public String getSize() {
        return size;
    }

    /**
     * 查找是否存在
     * @param size
     * @return
     */
    public static SizeEnum fromString(String size) {
        for (SizeEnum s : SizeEnum.values()) {
            if (s.size.equalsIgnoreCase(size)) {
                return s;
            }
        }
        throw new IllegalArgumentException("不存在该尺码");
    }

}